package com.xbongbong.workflow.model.impl;

import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.workflow.domain.dao.WorkflowTaskDao;
import com.xbongbong.workflow.domain.entity.WorkflowTaskEntity;
import com.xbongbong.workflow.model.WorkflowTaskModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 */
@Service("workflowTaskModel")
public class WorkflowTaskModelImpl implements WorkflowTaskModel {
    @Resource
    private WorkflowTaskDao workflowTaskDao;

    @Override
    public Long insert(WorkflowTaskEntity entity) {
        return workflowTaskDao.insert(entity);
    }

    @Override
    public void insertBatch(List<WorkflowTaskEntity> list) {
        workflowTaskDao.insertBatch(list);
    }

    @Override
    public List<WorkflowTaskEntity> findEntities(Map<String, Object> param) {
        return workflowTaskDao.findEntities(param);
    }

    @Override
    public Integer getEntityCount(Map<String, Object> param) {
        return workflowTaskDao.getEntitiesCount(param);
    }

    @Override
    public void update(WorkflowTaskEntity entity) {
        Long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        workflowTaskDao.update(entity);
    }

    @Override
    public WorkflowTaskEntity getByKey(Long key, String corpid) {
        return workflowTaskDao.getByKey(key, corpid);
    }

    @Override
    public void updateFlowStatusByTaskId(String corpid, Long taskId, Integer flowStatus) {
        workflowTaskDao.updateFlowStatusByTaskId(corpid, taskId, flowStatus);
    }

    @Override
    public void deleteByTaskIds(String corpid, List<Long> taskIds) {
        workflowTaskDao.deleteByTaskIds(corpid, taskIds);
    }

}
